package hb.software.selectcourse.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import hb.software.selectcourse.dao.SelectCourseDao;
import hb.software.selectcourse.entity.SelectCourse;
import hb.software.selectcourse.service.SelectCourseManager;
import serviceimpl.CommonStudentManagerimpl;

@Transactional
@Service("selectCourse")
/**
 * 
 * @author User implementation class inquire query selectname
 */
public class SelectCourseManagerImpl extends CommonStudentManagerimpl<SelectCourse, Long>
		implements SelectCourseManager {

	SelectCourseDao selectCourseDao;

	@Override
	public List<SelectCourse> findByName(String name) { // create query object

		SelectCourse queryObject = new SelectCourse();
		queryObject.setSelectname(name);
		ExampleMatcher matcher = ExampleMatcher.matching() // create object
				.withMatcher("name", GenericPropertyMatchers.startsWith()) // Names are searched by "start matching"
				.withIgnorePaths("dateCreated", "dateModified");
		// create query
		Example<SelectCourse> ex = Example.of(queryObject, matcher);
		List<SelectCourse> result = dao.findAll(ex);
		return result;
	}

	@Autowired
	public void setSelectCourseDao(SelectCourseDao selectCourseDao) {
		this.selectCourseDao = selectCourseDao;
		this.dao = this.selectCourseDao;

	}

}
